package com.spit.tph.nike_mvp.adapter;

/**
 * User: Nike
 * 2024/3/7 17:47
 */

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;
import android.widget.TextView;

import com.flyco.roundview.RoundTextView;
import com.flyco.roundview.RoundViewDelegate;
import com.spit.tph.R;
import com.yyc.stocktake.bean.DataBean;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * @data on 2020/9/5 10:41 AM
 * @auther armstrong
 * @describe   tagflowlayout 采自github泓洋大神的 FlowLayout库
 */
public class FlowTagAdapter extends TagAdapter {
    private List<DataBean> listBean;
    private Context context;

    public FlowTagAdapter(Context mcontext, List datas) {
        super(datas);
        this.context = mcontext;
        this.listBean = datas;
    }

    @Override
    public View getView(FlowLayout parent, int position, Object o) {
        DataBean bean = listBean.get(position);
        RoundTextView tv =  (RoundTextView)View.inflate(context, R.layout.i_fy_consumable, null);
        tv.setText(bean.getLocationName() + " (" + bean.getCurrentInventory() +
                ")");
        RoundViewDelegate delegate = tv.getDelegate();
        if (bean.getLocFlag() == 0){
            delegate.setBackgroundColor(ContextCompat.getColor(context, R.color.colorAccent));
        }else {
            delegate.setBackgroundColor(ContextCompat.getColor(context, R.color.yellow_ffc107));
        }
        return tv;
    }

    @Override
    public int getCount() {
        return listBean.size();
    }

    @Override
    public void onSelected(int position, View view) {
        super.onSelected(position, view);
    }

    @Override
    public void unSelected(int position, View view) {
        super.unSelected(position, view);
    }
}
